package org.roy.uibase.field;

import java.util.Vector;

import javax.microedition.lcdui.Graphics;

public class Container extends Field{
    private Layout iLayout;
   
    public void setLayout(Layout aLayout){
        iLayout = aLayout;
    }

    public void paint(Graphics aGraphics) {
        layout();
        paintBackgroud(aGraphics);
        paintChindren(aGraphics);
    }
    
    public void paintBackgroud(Graphics aGraphics){
        aGraphics.setColor(0xFFFFFF);
        aGraphics.fillRect(iBoundRect.left(), iBoundRect.top(), iBoundRect.getWidth(), iBoundRect.getHeight());
    }
    
    public void paintChindren(Graphics aGraphics){
        for(int i = 0; i < iLayout.getChildren().size(); i++){
            Field sField = iLayout.getField(i);
            sField.paint(aGraphics);
        }
    }
    
    public Vector getChildren(){
        return iLayout.getChildren();
    }
    
    public Field getField(int aIndex){
        return iLayout.getField(aIndex);
    }
    
    public Field getField(int ax, int ay){
        return iLayout.getFieldAt(ax, ay);
    }
    
    public void layout(){
        iLayout.layout();
    }

    public int minHeight() {
        return 0;
    }

    public int minWidth() {
        return 0;
    }
}
